public class HomeWork12_08{
    public static void main(String[] args){
        ArrDiagonal ad = new ArrDiagonal();
        
        int[][] arr = new int[6][6];
        int count = 1;
        for(int i = 0; i < 6; i++){
            for(int j = 0; j < 6; j++){
                arr[i][j] = count++;
            }
        }
        
        int ans1 = ad.arrDiagonalAns(arr, ArrDiagonal.Position.LeftUpToRightDown);
        System.out.println("左上至右下: " + ans1);
        int ans2 = ad.arrDiagonalAns(arr, ArrDiagonal.Position.RightUpToLeftDown);
        System.out.println("右上至坐下: " + ans2);
    }
}

class ArrDiagonal{
    public enum Position{
        LeftUpToRightDown, RightUpToLeftDown;
    }
    public int arrDiagonalAns(int[][] arr, Position pos){
        int tag = 0;
        int plus = 1;
        switch(pos){
        case LeftUpToRightDown: 
            break;
        case RightUpToLeftDown: 
            tag = arr.length - 1; 
            plus = -plus;
            break;
        default: 
            break;
        }
        
        int ans = 0;
        for(int i = 0; i < arr.length; i++){
            ans += arr[i][tag];
            tag += plus;
        }
        return ans;
    }
}